package com.example.demo.properties.prop;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotEmpty;

@Component
@ConfigurationProperties(prefix = "awo")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Validated
public class AppAwoProperties {
    private int id;

    private String name;
    @Max(45)
    private Integer age;
    @Email
    private String email;

    @Valid
    private final Security security = new Security();

    @Data
    public static class Security {
        @NotEmpty
        public String username;
    }
}
